<?php

use Phinx\Migration\AbstractMigration;

class AddTaskDefaultStatusConfig extends AbstractMigration
{
    public function up()
    {
        $status = [
            [
                'name' => '待发布', //已完成
                'code' => 'ready_to_publish',
                'color' => '#ff5500',
                'icon' => 'el-icon-success',
                'correspond' => 'done',
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ]
        ];

        $this->table("status")->insert($status)->save();
        $options = [
            [
                'name' => 'default_taskstatus',
                'type' => 'system',
                'config' => json_encode([
                    "default_status" => "not_started",
                    "default_reject_status" => "feedback",
                    "default_release_status" => "ready_to_publish",
                    "default_approval_status" => "inprogress",
                    "default_completion_status" => "final"
                ]),
                'uuid' => Webpatser\Uuid\Uuid::generate()->string
            ]
        ];
        $this->table('options')->insert($options)->save();
    }

    public function down()
    {
        $this->execute("DELETE from status where code='ready_to_publish'");
        $this->execute("DELETE from options where name='default_taskstatus'");

    }
}
